/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cl.darksigns.webstat.front.actions.delegate;

import cl.darksigns.webstat.back.ejb.StatBussinesLocal;

import cl.darksigns.webstat.back.exception.WebStatException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.apache.log4j.Logger;

/**
 *
 * @author _ViKtOr
 */
public class BusinessDelegate {
    
    Logger logger = Logger.getLogger(BusinessDelegate.class);
    StatBussinesLocal local ;

    private StatBussinesLocal lookupStatBussinesBean() throws WebStatException {
        try {
            Context c = new InitialContext();
            return (StatBussinesLocal) c.lookup("java:comp/env/StatBussinesBean");
        } catch (NamingException ne) {
            logger.error("Error finding : "  + "java:comp/env/StatBussinesBean");
            throw new WebStatException("Error finding business Service");
        }
    }
    
    public BusinessDelegate() throws WebStatException{
        local = lookupStatBussinesBean();
        
    }
    
    public boolean validateUser(String userName, String userPwd) throws WebStatException{
        return local.validateUser(userName, userPwd);
    }
    
    
    

}
